import {Button, Form, Input, message} from "antd";
import React from "react";
import {postFetch} from "@/app/lib/HttpProtocol";

const apis = {
	selfChangePasswordApi:'/auth/changePassoword',
}

export default function SelfChangePasswordForm({onComplete}:{onComplete:any}){
	const [form] = Form.useForm();
	const onFinish = (values: any) => {
	  postFetch(apis.selfChangePasswordApi,{values}).then(data => {
			message.success('修改成功')
			onComplete();
		}).catch(e => {
		
		})
	}
	return (
		<Form layout={"horizontal"} form={form}
					labelCol={{ span: 4 }}
					wrapperCol={{ span: 12 }} size={"small"}
					onFinish={onFinish}
		>
			<Form.Item
				name="oldPassword"
				label="旧密码"
				rules={[{ required: true}]}
			>
				<Input.Password />
			</Form.Item>
			<Form.Item
				name="newPassword"
				label="新密码"
				rules={[{ required: true}]}
			>
				<Input.Password />
			</Form.Item>
				<Form.Item wrapperCol={{ offset: 13, span: 16 }}>
				<Button type="primary" htmlType="submit">
					确定
				</Button>
			</Form.Item>
		</Form>
	);
}